package xworker.javafx.stage;

import javafx.stage.Window;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class WindowActions {
	static{
		PropertyFactory.regist(Window.class, "onCloseRequestProperty", o -> {
			Window obj = (Window) o;
			return obj.onCloseRequestProperty();
		});
		PropertyFactory.regist(Window.class, "renderScaleYProperty", o -> {
			Window obj = (Window) o;
			return obj.renderScaleYProperty();
		});
		PropertyFactory.regist(Window.class, "renderScaleXProperty", o -> {
			Window obj = (Window) o;
			return obj.renderScaleXProperty();
		});
		PropertyFactory.regist(Window.class, "forceIntegerRenderScaleProperty", o -> {
			Window obj = (Window) o;
			return obj.forceIntegerRenderScaleProperty();
		});
		PropertyFactory.regist(Window.class, "eventDispatcherProperty", o -> {
			Window obj = (Window) o;
			return obj.eventDispatcherProperty();
		});
		PropertyFactory.regist(Window.class, "onShownProperty", o -> {
			Window obj = (Window) o;
			return obj.onShownProperty();
		});
		PropertyFactory.regist(Window.class, "onShowingProperty", o -> {
			Window obj = (Window) o;
			return obj.onShowingProperty();
		});
		PropertyFactory.regist(Window.class, "onHiddenProperty", o -> {
			Window obj = (Window) o;
			return obj.onHiddenProperty();
		});
		PropertyFactory.regist(Window.class, "opacityProperty", o -> {
			Window obj = (Window) o;
			return obj.opacityProperty();
		});
		PropertyFactory.regist(Window.class, "onHidingProperty", o -> {
			Window obj = (Window) o;
			return obj.onHidingProperty();
		});
	}

	public static void init(Thing thing, Window window, ActionContext actionContext) {
		if(thing.valueExists("width")) {
			window.setWidth(thing.getDouble("width"));
		}
		if(thing.valueExists("height")) {
			window.setHeight(thing.getDouble("height"));
		}
		if(thing.valueExists("x")) {
			window.setX(thing.getDouble("x"));
		}
		if(thing.valueExists("y")) {
			window.setY(thing.getDouble("y"));
		}
		if(thing.valueExists("opacity")){
			window.setOpacity(thing.getDouble("opacity"));
		}
	}
}
